package com.webcash.CNBoard.Service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webcash.CNBoard.Model.CreateWork;
import com.webcash.CNBoard.Model.Employee;
import com.webcash.CNBoard.Model.Work;
import com.webcash.CNBoard.Repository.EmployeeRepository;
import com.webcash.CNBoard.Repository.WorkRepository;
import com.webcash.CNBoard.Repository.WorkTracerRepository;

@Service
public class CreateWorkServiceImpl implements CreateWorkService {

	@Autowired 
	WorkRepository workRepository;
	@Autowired
	EmployeeRepository employeeRepository;

	private static int NOT_EXIST_ID = 0;
	private static int NOT_EXIST_NO = 1;
	private static int SUCCESS = 3;
	
	public int cheackValidation(CreateWork createWork) {

		Employee emp = employeeRepository.selectEmployeeById(createWork.getId());
		
		if(emp==null)
			return NOT_EXIST_ID;
		
		Work work = workRepository.selectWorkByWorkNo(createWork.getUpperWorkNo());
		if(work == null)
			return NOT_EXIST_NO;
		
		return SUCCESS;
	}


}
